package com.cncn.db;

import com.cncn.entity.LotteryLaunchEntity;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String DB_NAME = "lottery.db";
	private static final int DB_VERSION = 1;
	
	public DatabaseHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(PrizeTable.createTable());
		db.execSQL(LotteryLaunchTable.createTable());
		db.execSQL(LotteryJoinTable.createTable());
		db.execSQL(LotteryResult.createTable());
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
	}
	
	public void insert(LotteryLaunchEntity entity) {
		String sql = LotteryLaunchTable.insertSql(entity.getUser_id(), entity.getUser_point(), entity.getPrize_id());
		SQLiteDatabase db = getWritableDatabase();
		db.execSQL(sql);
	}

}
